/**
 * @(#)MaximumScoredNumber.java 
 * 
 * TopCoder SRM 411 DIV 2 250 Point
 *
 * Author:     GGshiney        
 * Version :          
 * Date:       2008-8-5
 */
import java.util.Vector;

public class MaximumScoredNumber {
    Vector<Integer> sqr = new Vector<Integer>();

    int x;

    public int getNumber(int lowerBound, int upperBound) {
	int count;
	int maxCount = 0;

	for (int i = 0; i * i <= upperBound; i++) {
	    sqr.addElement(i * i);
	}

	for (int i = lowerBound; i <= upperBound; i++) {
	    count = 0;
	    for (int j = 0; (j < sqr.size()) && (sqr.get(j) * 2 <= i); j++) {
		if (sqr.indexOf(i - sqr.get(j)) > 0) {
		    count++;
		}

	    }
	    if (count >= maxCount) {
		maxCount = count;
		x = i;
	    }
	}
	return x;
    }
}
